package org.example.springmvc.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * ClassName: Hello07Controller
 * Package: org.example.springmvc.controller
 * Description:
 *
 * @Author wanghao
 * @Create 2024-07-11 17:20
 * @Version 1.0
 */
@Controller
@RequestMapping("/hello07")
public class Hello07Controller {

    // 1. 演示获取原生的ServletAPI, HttpServletRequest, HttpServletResponse, HttpSession
    @RequestMapping("/h01")
    public String h01(HttpServletRequest request, HttpServletResponse response, HttpSession session) {
        System.out.println(request);
        System.out.println(response);
        System.out.println(session);
        return "succ";
    }

    @Autowired
    private ServletContext ctx;

    // 2. 演示获取原生的ServletAPI, ServletContext
    @RequestMapping("/h02")
    public String h02(HttpServletRequest request, HttpServletResponse response, HttpSession session) {
        System.out.println(request.getServletContext());
        System.out.println(session.getServletContext());
        System.out.println(ctx);
        return "succ";
    }

}
